﻿ 
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Sharp.Domain.PlatformBoundedContext.PersonModule.Aggregates;

namespace Sharp.Domain.PlatformBoundedContext.ModelConfigurations
{
    public partial class JobConfiguration
        : EntityTypeConfiguration<Job>
    {
        public JobConfiguration()
        { 
            HasKey(x => x.Id);

            Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();

            Property(t => t.Title)
                .HasMaxLength(50)
                .IsRequired();
            Property(t => t.ParentId)
               .IsOptional();
            Property(t => t.OrderIndex)
               .IsOptional();
 
            Property(t => t.Qualifications)
                .HasMaxLength(200)
                .IsOptional();
            Property(t => t.Remark)
                .HasMaxLength(255)
                .IsOptional();
 
            Property(t => t.CheckInTime)
                .IsRequired();
            Property(t => t.CheckInUserId)
                .IsRequired();
            Property(t => t.ModifiTime)
                .IsOptional();
            Property(t => t.ModifiedUserId)
                .IsOptional();
           
            // Relationships

            //HasOptional(t => t.Grade)
            //          .WithMany(t => t.Jobs)
            //          .HasForeignKey(d => d.GradeCode);

        }
    }
}

